#include<stdio.h>
#include<ctype.h>
#include<assert.h>
//atoi模拟实现
int Atoi(char* arr)
{
	assert(arr);
	int longth, flag, sum;
	char* end = NULL;
	while (end++ != '\0');
	flag = 1, sum = 0;
	longth = end - arr;
	
	//首字符带符号（'-'）
	if (*arr == '-') {
		flag = -1;
		arr++;
	}
	else if (*arr == '+')
		arr++;

	//首字符非空也非数字字符
	if (!isspace(*arr) && !(*arr < '9' && *arr>'0'))
		return 0;
	
	//首字符是空字符
	while (isspace(*arr))
		arr++;

	while (*arr < '9' && *arr>'0') {
		sum = 10 * sum + (*arr - '0');
		arr++;
	}
		return sum * flag;
}
int main()
{
	char arr[] = "+2a4";
	int ret = Atoi(arr);
	printf("%d\n", ret);
	return 0;
}